package com.xuan.friend.controller.question;

import com.xuan.common.core.controller.BaseController;
import com.xuan.common.core.domain.R;
import com.xuan.common.core.domain.TableDataInfo;
import com.xuan.common.core.exception.BusinessException;
import com.xuan.friend.domain.question.dto.QuestionQueryDTO;
import com.xuan.friend.domain.question.vo.HotQuestionVo;
import com.xuan.friend.domain.question.vo.QuestionDetailVo;
import com.xuan.friend.service.question.QuestionService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/question")
public class QuestionController extends BaseController {

    @Resource
    private QuestionService questionService;

    @GetMapping("/semiLogin/list")
    public TableDataInfo listQuestion(QuestionQueryDTO questionQueryDTO) {
        return questionService.listQuestion(questionQueryDTO);
    }


    @GetMapping("/detail")
    public R<QuestionDetailVo> questionDetail(Long questionId, Long contestId) {
        if (questionId == null || questionId <= 0) {
            throw new BusinessException("参数为空");
        }
        return R.ok(questionService.questionDetail(questionId, contestId));
    }


    @GetMapping("/prevQuestion")
    public R<String> prevQuestion(Long questionId) {
        if (questionId == null || questionId <= 0) {
            throw new BusinessException("参数为空");
        }
        return R.ok(questionService.prevQuestion(questionId));
    }

    @GetMapping("/nextQuestion")
    public R<String> nextQuestion(Long questionId) {
        if (questionId == null || questionId <= 0) {
            throw new BusinessException("参数为空");
        }
        return R.ok(questionService.nextQuestion(questionId));
    }


    @GetMapping("/semiLogin/hot/list")
    public R<List<HotQuestionVo>> getHotQuestionList() {
        return R.ok(questionService.getHotQuestionList());
    }
}
